package com.FQJ.stock.config;

import com.FQJ.stock.pojo.vo.StockInfoConfig;
import com.FQJ.stock.utils.IdWorker;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
// / ***
// * @Description 定义公共配置类
// 		*/
@Configuration
@EnableConfigurationProperties({StockInfoConfig.class})//开启相关配置类的加载
public class CommonConfig {
	/**
	 * 密码加密器
	 * BCryptPasswordEncoder方法采用SHA-256对密码进行加密
	 * @return
	 */
	@Bean
	public PasswordEncoder passwordEncoder(){
		return new BCryptPasswordEncoder();
	}
	/**
	 * 配置ID生成器
	 * @return
	 */
	@Bean//如果写成了静态方法，就没必要写成bean
	public IdWorker idWorker(){
		//基于2号机房的1号机器生成的id
		return new IdWorker(1l,2l);
	}

}

